select qtde_total,valor_total,* 
from loja_saidas 
where numero_nf_transferencia = '002972'
and substring(filial,1,3) = '525' 

select *
from loja_saidas_produto
where romaneio_produto = 'AA5050'
and substring(filial,1,3) = '525' 

select * from loja_saidas_produtos wheAA5050  

select qtde_total,valor_total,* from loja_saidas where numero_nf_transferencia = '99887766'
select sum(qtde_saida),sum(valor) from loja_saidas_produto where romaneio_produto in
('AA694140')

select top 3 *
from loja_saidas 
where substring(FILIAL,1,3) ='556' and substring(FILIAL_DESTINO,1,3) = '5556'
order by numero_nf_transferencia desc
 
select top 5 qtde_total,valor_total,* from loja_saidas 

select * from loja_entradas  where numero_nf_transferencia = '99887766'

select top 10 qtde_total,valor_total,* from loja_entradas  where numero_nf_transferencia = '002971'

select qtde_total,valor_total,* from loja_entradas where numero_nf_transferencia = '99887766'

select * from loja_entradas_produto where romaneio_produto in
('AA767325')


/*
begin transaction
delete from loja_entradas  where numero_nf_transferencia = '99887766'
commit

*/

/*
select top 10 * from loja_saidas where numero_nf_transferencia = '99887766'
select top 10 * from loja_entradas

4992	152046.18
begin transaction
update loja_saidas
set numero_nf_transferencia = '002972'
where numero_nf_transferencia = '99887766'
commit
rollback
*/

select sum(qtde_saida),sum(valor) from loja_entradas_produto where romaneio_produto in
('AA693597')
select * from loja_entradas_produto where romaneio_produto in
('AA693597')


SELECT SUM(A.QTDE_TOTAL),SUM(A.VALOR_TOTAL) 
 FROM LOJA_SAIDAS A
 WHERE SUBSTRING(A.FILIAL,1,3) = '556'
 AND SUBSTRING(A.FILIAL_DESTINO,1,3) = '525'
-- AND DATEPART(YYYY,A.EMISSAO) = 2008
AND RTRIM(LTRIM(A.NUMERO_NF_TRANSFERENCIA)) IN 
('000001','000001','000002','000002','000003','000004','000005','000006','000007','000008'
,'000009','000010','000010','000011','000014','000015','000017','000018','000712','001109'
,'1234567','260234','260235','260236','260237','260238','260239','260240','260241','260242'
,'260243','260244','260245','260246')


----SUMARIZANDO O TOTAL DA NOTA
--SELECT @QTDE_TOTAL = SUM(A.QTDE_TOTAL),@VALOR_TOTAL = SUM(A.VALOR_TOTAL) 
-- FROM LOJA_SAIDAS A
-- WHERE SUBSTRING(A.FILIAL,1,3) = '556'
-- AND SUBSTRING(A.FILIAL_DESTINO,1,3) = '525'
---- AND DATEPART(YYYY,A.EMISSAO) = 2008
--AND RTRIM(LTRIM(A.NUMERO_NF_TRANSFERENCIA)) IN 
--('000001','000001','000002','000002','000003','000004','000005','000006','000007','000008'
--,'000009','000010','000010','000011','000014','000015','000017','000018','000712','001109'
--,'1234567','260234','260235','260236','260237','260238','260239','260240','260241','260242'
--,'260243','260244','260245','260246')
--
----('280134','280135','280136','280137','280138','280139','280140','280141','280142','280143','280144','280145'
----,'280146','280147','280148','280149','280150','280151','280152','280153','280154','280155','280156','280157'
----,'280158','280159','280160','280161','280162','280163','280164','280165','280166','280167','280168','280169'
----,'280170','280171','280186','280172','280173','280174','280175','27','280177','38','280178','280179','280180'
----,'280181','280182','7700','280183','280184','280185')

lx_processos